I've tried multiple ways of setting the background-color of a DropDownList,
but none seem to work.
How can the color be set?
I've tried setting the BackGroundColor of the DrowDownList component, and
also setting it for each of the List Items.
The resulting .html code looks correct. Why doesn't the color display?
Code
DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue;
DropDownListWorkLocation.ControlStyle.BackColor =
System.Drawing.Color.PowderBlue;
DropDownListWorkLocation.Attributes.CssStyle.Add(" background-repeat",
"repeat-y");
DropDownListWorkLocation.Attributes.CssStyle.Add(" background-color",
"powderblue");
DropDownListWorkLocation.Items[0].Attributes.Add("style",
"color:powderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items[i].Attributes.Add("style",
"background-color:powderblue; ");
}
Resulting HTML
<td style="height: 20px;" nowrap="noWrap" width="19%">
<select name="DropDownListWorkLocation" id="DropDownListWorkLocation"
tabindex="9"
style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;">
<option selected="selected" value="" style="background-color:powderblue;
"></option>
<option value="123 Main Street" style="background-color:powderblue; ">123
Main Street</option>
<option value="456 Boulevard" style="background-color:powderblue; ">456
Boulevard</option>
<option value="789 Avenue" style="background-color:powderblue; ">789
Avenue</option>
</select>
</td> 10 2223
Hi, Cliff.
Use :
DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");
If you want to apply different colors to different rows, adapt this :
If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If
....or some such variation.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work.
How can the color be set?
I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List Items.
The resulting .html code looks correct. Why doesn't the color display?
Code
DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue;
DropDownListWorkLocation.ControlStyle.BackColor = System.Drawing.Color.PowderBlue;
DropDownListWorkLocation.Attributes.CssStyle.Add(" background-repeat", "repeat-y");
DropDownListWorkLocation.Attributes.CssStyle.Add(" background-color", "powderblue");
DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue");
for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++)
{
DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; ");
}
Resulting HTML
<td style="height: 20px;" nowrap="noWrap" width="19%">
<select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9"
style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;">
<option selected="selected" value="" style="background-color:powderblue; "></option>
<option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option>
<option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option>
<option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option>
</select>
</td>
I should have added that you can set both the background
and foreground colors in the same style properties, but you know that, right ?
Attributes.Add("style", "background: red; color: white;")
....would give you white letters on a red background.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl...
Hi, Cliff.
Use :
DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");
If you want to apply different colors to different rows, adapt this :
If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If
...or some such variation.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
>I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. How can the color be set?
I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List Items. The resulting .html code looks correct. Why doesn't the color display?
Code DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.ControlStyle.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.Attributes.CssStyle.Add( "background-repeat", "repeat-y"); DropDownListWorkLocation.Attributes.CssStyle.Add( "background-color", "powderblue"); DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue"); for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) { DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; "); }
Resulting HTML
<td style="height: 20px;" nowrap="noWrap" width="19%"> <select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9" style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> <option selected="selected" value="" style="background-color:powderblue; "></option> <option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option> <option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option> <option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option> </select> </td>
I tried it and the background-color still shows as a dark gray.
Here's the HTML it produced:
<select name="DropDownListWorkLocation" id="DropDownListWorkLocation"
tabindex="9" style="font-weight:bold;width:90%;background:powderblue">
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OD**************@TK2MSFTNGP06.phx.gbl...
Hi, Cliff.
Use :
DropDownListWorkLocation.Attributes.Add("style", "background:powderblue");
If you want to apply different colors to different rows, adapt this :
If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then
DropDownListWorkLocation.Attributes.Add("style", "background:red")
Else
DropDownListWorkLocation.Attributes.Add("style", "background:yellow")
End If
...or some such variation.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. How can the color be set?
I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List Items. The resulting .html code looks correct. Why doesn't the color display?
Code DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.ControlStyle.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.Attributes.CssStyle.Add( "background-repeat", "repeat-y"); DropDownListWorkLocation.Attributes.CssStyle.Add( "background-color", "powderblue"); DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue"); for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) { DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; "); }
Resulting HTML
<td style="height: 20px;" nowrap="noWrap" width="19%"> <select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9" style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> <option selected="selected" value="" style="background-color:powderblue; "></option> <option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option> <option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option> <option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option> </select> </td>
That works with red and white, maybe there is a problem with
System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:e%****************@TK2MSFTNGP06.phx.gbl...
>I should have added that you can set both the background
and foreground colors in the same style properties, but you know that,
right ?
Attributes.Add("style", "background: red; color: white;")
...would give you white letters on a red background.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OD**************@TK2MSFTNGP06.phx.gbl...
>Hi, Cliff.
Use :
DropDownListWorkLocation.Attributes.Add("style" , "background:powderblue");
If you want to apply different colors to different rows, adapt this :
If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then DropDownListWorkLocation.Attributes.Add("style" , "background:red") Else DropDownListWorkLocation.Attributes.Add("style" , "background:yellow") End If
...or some such variation.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
>>I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. How can the color be set?
I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List Items. The resulting .html code looks correct. Why doesn't the color display?
Code DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.ControlStyle.BackColo r = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.Attributes.CssStyle.Add ("background-repeat", "repeat-y"); DropDownListWorkLocation.Attributes.CssStyle.Add ("background-color", "powderblue"); DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue"); for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) { DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; "); }
Resulting HTML
<td style="height: 20px;" nowrap="noWrap" width="19%"> <select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9" style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> <option selected="selected" value="" style="background-color:powderblue; "></option> <option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option> <option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option> <option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option> </select> </td>
re:
!That works with red and white, maybe there is a problem with
!System.Drawing.Color.PowderBlue not being recognized ?
According to : http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx
....it should be recognized.
PowderBlue is a system-defined color.
Instead of passing the whole qualified name, try passing just the color name itself:
i.e., instead of :
System.Drawing.Color.PowderBlue;
use :
PowderBlue;
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl...
That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl...
>>I should have added that you can set both the background and foreground colors in the same style properties, but you know that, right ?
Attributes.Add("style", "background: red; color: white;")
...would give you white letters on a red background. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl...
>>Hi, Cliff.
Use :
DropDownListWorkLocation.Attributes.Add("style ", "background:powderblue");
If you want to apply different colors to different rows, adapt this :
If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then DropDownListWorkLocation.Attributes.Add("style ", "background:red") Else DropDownListWorkLocation.Attributes.Add("style ", "background:yellow") End If
...or some such variation.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl... I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. How can the color be set?
I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List Items. The resulting .html code looks correct. Why doesn't the color display?
Code DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.ControlStyle.BackCol or = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.Attributes.CssStyle.Ad d("background-repeat", "repeat-y"); DropDownListWorkLocation.Attributes.CssStyle.Ad d("background-color", "powderblue"); DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue"); for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) { DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; "); }
Resulting HTML
<td style="height: 20px;" nowrap="noWrap" width="19%"> <select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9" style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> <option selected="selected" value="" style="background-color:powderblue; "></option> <option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option> <option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option> <option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option> </select> </td>
See PowderBlue rendered in my example at : http://asp.net.do/test/dropdowncolor3.aspx
That example uses :
DDL1.Items(i).Attributes.Add("style", "background:PowderBlue")
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP04.phx.gbl...
re:
!That works with red and white, maybe there is a problem with
!System.Drawing.Color.PowderBlue not being recognized ?
According to :
http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx
...it should be recognized.
PowderBlue is a system-defined color.
Instead of passing the whole qualified name, try passing just the color name itself:
i.e., instead of :
System.Drawing.Color.PowderBlue;
use :
PowderBlue;
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl...
>That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl...
>>>I should have added that you can set both the background and foreground colors in the same style properties, but you know that, right ?
Attributes.Add("style", "background: red; color: white;")
...would give you white letters on a red background. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl... Hi, Cliff.
Use :
DropDownListWorkLocation.Attributes.Add("style" , "background:powderblue");
If you want to apply different colors to different rows, adapt this :
If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then DropDownListWorkLocation.Attributes.Add("style" , "background:red") Else DropDownListWorkLocation.Attributes.Add("style" , "background:yellow") End If
...or some such variation.
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl... I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. How can the color be set? > I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List Items. The resulting .html code looks correct. Why doesn't the color display? > Code DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.ControlStyle.BackColo r = System.Drawing.Color.PowderBlue; DropDownListWorkLocation.Attributes.CssStyle.A dd("background-repeat", "repeat-y"); DropDownListWorkLocation.Attributes.CssStyle.A dd("background-color", "powderblue"); DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue"); for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) { DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; "); } > Resulting HTML > <td style="height: 20px;" nowrap="noWrap" width="19%"> <select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9" style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> <option selected="selected" value="" style="background-color:powderblue; "></option> <option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option> <option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option> <option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option> </select> </td> > >
I tried that and background:blue changes the color to blue, but
background:PowderBlue displays as dark gray:
DropDownListWorkLocation.Items[i].Attributes.Add("style",
"background:PowderBlue; ");
It looks like it recognizes basic colors like red, blue, white, black ....
but not all of those defined in System.Drawing.Color
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:ei**************@TK2MSFTNGP06.phx.gbl...
See PowderBlue rendered in my example at :
http://asp.net.do/test/dropdowncolor3.aspx
That example uses :
DDL1.Items(i).Attributes.Add("style", "background:PowderBlue")
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
>re: !That works with red and white, maybe there is a problem with !System.Drawing.Color.PowderBlue not being recognized ?
According to :
http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx
...it should be recognized.
PowderBlue is a system-defined color.
Instead of passing the whole qualified name, try passing just the color name itself:
i.e., instead of : System.Drawing.Color.PowderBlue;
use : PowderBlue; Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl...
>>That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl.. . I should have added that you can set both the background and foreground colors in the same style properties, but you know that, right ?
Attributes.Add("style", "background: red; color: white;")
...would give you white letters on a red background. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl... Hi, Cliff. > Use : > DropDownListWorkLocation.Attributes.Add("style ", "background:powderblue"); > If you want to apply different colors to different rows, adapt this : > If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then DropDownListWorkLocation.Attributes.Add("style ", "background:red") Else DropDownListWorkLocation.Attributes.Add("style ", "background:yellow") End If > ...or some such variation. > > > > > Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl.. . >I've tried multiple ways of setting the background-color of a >DropDownList, but none seem to work. >How can the color be set? >> >I've tried setting the BackGroundColor of the DrowDownList component, >and also setting it for each of the List Items. >The resulting .html code looks correct. Why doesn't the color >display? >> >Code >DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; >DropDownListWorkLocation.ControlStyle.BackCol or = >System.Drawing.Color.PowderBlue; >DropDownListWorkLocation.Attributes.CssStyle. Add("background-repeat", >"repeat-y"); >DropDownListWorkLocation.Attributes.CssStyle. Add("background-color", >"powderblue"); >DropDownListWorkLocation.Items[0].Attributes.Add("style", >"color:powderblue"); >for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) >{ >DropDownListWorkLocation.Items[i].Attributes.Add("style", >"background-color:powderblue; "); >} >> >Resulting HTML >> ><td style="height: 20px;" nowrap="noWrap" width="19%"> ><select name="DropDownListWorkLocation" id="DropDownListWorkLocation" >tabindex="9" >style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> ><option selected="selected" value="" >style="background-color:powderblue; "></option> ><option value="123 Main Street" style="background-color:powderblue; >">123 Main Street</option> ><option value="456 Boulevard" style="background-color:powderblue; >">456 Boulevard</option> ><option value="789 Avenue" style="background-color:powderblue; ">789 >Avenue</option> ></select> ></td> >> >> > >
Cliff,
See PowderBlue rendered in my example at : http://asp.net.do/test/dropdowncolor3.aspx
How does that appear when you view it ?
Can you see PowderBlue...or do you see dark gray ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
>I tried that and background:blue changes the color to blue, but background:PowderBlue displays as dark gray:
DropDownListWorkLocation.Items[i].Attributes.Add("style", "background:PowderBlue; ");
It looks like it recognizes basic colors like red, blue, white, black .... but not all of those defined in
System.Drawing.Color
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:ei**************@TK2MSFTNGP06.phx.gbl...
>See PowderBlue rendered in my example at :
http://asp.net.do/test/dropdowncolor3.aspx
That example uses :
DDL1.Items(i).Attributes.Add("style", "background:PowderBlue")
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP04.phx.gbl...
>>re: !That works with red and white, maybe there is a problem with !System.Drawing.Color.PowderBlue not being recognized ?
According to :
http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx
...it should be recognized.
PowderBlue is a system-defined color.
Instead of passing the whole qualified name, try passing just the color name itself:
i.e., instead of : System.Drawing.Color.PowderBlue;
use : PowderBlue; Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl... That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ?
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl... >I should have added that you can set both the background and foreground colors in the same style properties, but you know that, right ? > Attributes.Add("style", "background: red; color: white;") > ...would give you white letters on a red background. > > > Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl... >Hi, Cliff. >> >Use : >> >DropDownListWorkLocation.Attributes.Add("styl e", "background:powderblue"); >> >If you want to apply different colors to different rows, adapt this : >> >If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then >DropDownListWorkLocation.Attributes.Add("styl e", "background:red") >Else >DropDownListWorkLocation.Attributes.Add("styl e", "background:yellow") >End If >> >...or some such variation. >> >> >> >> >> >Juan T. Llibre, asp.net MVP >asp.net faq : http://asp.net.do/faq/ >foros de asp.net, en español : http://asp.net.do/foros/ >====================================== >"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl... >>I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. >>How can the color be set? >>> >>I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List >>Items. >>The resulting .html code looks correct. Why doesn't the color display? >>> >>Code >>DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; >>DropDownListWorkLocation.ControlStyle.BackCo lor = System.Drawing.Color.PowderBlue; >>DropDownListWorkLocation.Attributes.CssStyle .Add("background-repeat", "repeat-y"); >>DropDownListWorkLocation.Attributes.CssStyle .Add("background-color", "powderblue"); >>DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue"); >>for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) >>{ >>DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; "); >>} >>> >>Resulting HTML >>> >><td style="height: 20px;" nowrap="noWrap" width="19%"> >><select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9" >>style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> >><option selected="selected" value="" style="background-color:powderblue; "></option> >><option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option> >><option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option> >><option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option> >></select> >></td> >>> >>> >> >> > >
I can see a greenish-blue / aqua / turquoise color. Not dark gray, and not
the same as PowderBlue displays (here).
Your scroll bar components look more like PowderBlue.
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Cliff,
See PowderBlue rendered in my example at :
http://asp.net.do/test/dropdowncolor3.aspx
How does that appear when you view it ?
Can you see PowderBlue...or do you see dark gray ?
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>>I tried that and background:blue changes the color to blue, but background:PowderBlue displays as dark gray: DropDownListWorkLocation.Items[i].Attributes.Add("style", "background:PowderBlue; "); It looks like it recognizes basic colors like red, blue, white, black .... but not all of those defined in System.Drawing.Color
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:ei**************@TK2MSFTNGP06.phx.gbl...
>>See PowderBlue rendered in my example at :
http://asp.net.do/test/dropdowncolor3.aspx
That example uses :
DDL1.Items(i).Attributes.Add("style", "background:PowderBlue")
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP04.phx.gbl... re: !That works with red and white, maybe there is a problem with !System.Drawing.Color.PowderBlue not being recognized ?
According to :
http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx
...it should be recognized.
PowderBlue is a system-defined color.
Instead of passing the whole qualified name, try passing just the color name itself:
i.e., instead of : System.Drawing.Color.PowderBlue;
use : PowderBlue; Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl... That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized ? > > "Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl.. . >>I should have added that you can set both the background >and foreground colors in the same style properties, but you know >that, right ? >> >Attributes.Add("style", "background: red; color: white;") >> >...would give you white letters on a red background. >> >> >> >Juan T. Llibre, asp.net MVP >asp.net faq : http://asp.net.do/faq/ >foros de asp.net, en español : http://asp.net.do/foros/ >====================================== >"Juan T. Llibre" <no***********@nowhere.comwrote in message >news:OD**************@TK2MSFTNGP06.phx.gbl. .. >>Hi, Cliff. >>> >>Use : >>> >>DropDownListWorkLocation.Attributes.Add("sty le", >>"background:powderblue"); >>> >>If you want to apply different colors to different rows, adapt this >>: >>> >>If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then >>DropDownListWorkLocation.Attributes.Add("sty le", "background:red") >>Else >>DropDownListWorkLocation.Attributes.Add("sty le", >>"background:yellow") >>End If >>> >>...or some such variation. >>> >>> >>> >>> >>> >>Juan T. Llibre, asp.net MVP >>asp.net faq : http://asp.net.do/faq/ >>foros de asp.net, en español : http://asp.net.do/foros/ >>====================================== >>"Cliff Cotterill" <cl*************@intusurg.comwrote in message >>news:%2****************@TK2MSFTNGP02.phx.gbl ... >>>I've tried multiple ways of setting the background-color of a >>>DropDownList, but none seem to work. >>>How can the color be set? >>>> >>>I've tried setting the BackGroundColor of the DrowDownList >>>component, and also setting it for each of the List Items. >>>The resulting .html code looks correct. Why doesn't the color >>>display? >>>> >>>Code >>>DropDownListWorkLocation.BackColor = >>>System.Drawing.Color.PowderBlue; >>>DropDownListWorkLocation.ControlStyle.BackC olor = >>>System.Drawing.Color.PowderBlue; >>>DropDownListWorkLocation.Attributes.CssStyl e.Add("background-repeat", >>>"repeat-y"); >>>DropDownListWorkLocation.Attributes.CssStyl e.Add("background-color", >>>"powderblue"); >>>DropDownListWorkLocation.Items[0].Attributes.Add("style", >>>"color:powderblue"); >>>for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) >>>{ >>>DropDownListWorkLocation.Items[i].Attributes.Add("style", >>>"background-color:powderblue; "); >>>} >>>> >>>Resulting HTML >>>> >>><td style="height: 20px;" nowrap="noWrap" width="19%"> >>><select name="DropDownListWorkLocation" >>>id="DropDownListWorkLocation" tabindex="9" >>>style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> >>><option selected="selected" value="" >>>style="background-color:powderblue; "></option> >>><option value="123 Main Street" style="background-color:powderblue; >>>">123 Main Street</option> >>><option value="456 Boulevard" style="background-color:powderblue; >>>">456 Boulevard</option> >>><option value="789 Avenue" style="background-color:powderblue; >>>">789 Avenue</option> >>></select> >>></td> >>>> >>>> >>> >>> >> >> > >
Are you sure you don't suffer from daltonism ?
<only kidding...>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
>I can see a greenish-blue / aqua / turquoise color. Not dark gray, and not the same as PowderBlue displays (here).
Your scroll bar components look more like PowderBlue.
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2****************@TK2MSFTNGP04.phx.gbl...
>Cliff,
See PowderBlue rendered in my example at :
http://asp.net.do/test/dropdowncolor3.aspx
How does that appear when you view it ? Can you see PowderBlue...or do you see dark gray ?
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:%2****************@TK2MSFTNGP05.phx.gbl...
>>>I tried that and background:blue changes the color to blue, but background:PowderBlue displays as dark gray: DropDownListWorkLocation.Items[i].Attributes.Add("style", "background:PowderBlue; "); It looks like it recognizes basic colors like red, blue, white, black .... but not all of those defined in System.Drawing.Color
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:ei**************@TK2MSFTNGP06.phx.gbl... See PowderBlue rendered in my example at :
http://asp.net.do/test/dropdowncolor3.aspx
That example uses :
DDL1.Items(i).Attributes.Add("style", "background:PowderBlue")
Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2***************@TK2MSFTNGP04.phx.gbl... re: !That works with red and white, maybe there is a problem with !System.Drawing.Color.PowderBlue not being recognized ? > According to : > http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx > ...it should be recognized. > PowderBlue is a system-defined color. > Instead of passing the whole qualified name, try passing just the color name itself: > i.e., instead of : System.Drawing.Color.PowderBlue; > use : PowderBlue; > > > Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Cliff Cotterill" <cl*************@intusurg.comwrote in message news:uq**************@TK2MSFTNGP05.phx.gbl... >That works with red and white, maybe there is a problem with System.Drawing.Color.PowderBlue not being recognized >? >> >> >"Juan T. Llibre" <no***********@nowhere.comwrote in message news:e%****************@TK2MSFTNGP06.phx.gbl... >>>I should have added that you can set both the background >>and foreground colors in the same style properties, but you know that, right ? >>> >>Attributes.Add("style", "background: red; color: white;") >>> >>...would give you white letters on a red background. >>> >>> >>> >>Juan T. Llibre, asp.net MVP >>asp.net faq : http://asp.net.do/faq/ >>foros de asp.net, en español : http://asp.net.do/foros/ >>====================================== >>"Juan T. Llibre" <no***********@nowhere.comwrote in message news:OD**************@TK2MSFTNGP06.phx.gbl... >>>Hi, Cliff. >>>> >>>Use : >>>> >>>DropDownListWorkLocation.Attributes.Add("st yle", "background:powderblue"); >>>> >>>If you want to apply different colors to different rows, adapt this : >>>> >>>If ds.Tables(0).Rows(i)("UnitPrice") <= 40 Then >>>DropDownListWorkLocation.Attributes.Add("st yle", "background:red") >>>Else >>>DropDownListWorkLocation.Attributes.Add("st yle", "background:yellow") >>>End If >>>> >>>...or some such variation. >>>> >>>> >>>> >>>> >>>> >>>Juan T. Llibre, asp.net MVP >>>asp.net faq : http://asp.net.do/faq/ >>>foros de asp.net, en español : http://asp.net.do/foros/ >>>====================================== >>>"Cliff Cotterill" <cl*************@intusurg.comwrote in message >>>news:%2****************@TK2MSFTNGP02.phx.gb l... >>>>I've tried multiple ways of setting the background-color of a DropDownList, but none seem to work. >>>>How can the color be set? >>>>> >>>>I've tried setting the BackGroundColor of the DrowDownList component, and also setting it for each of the List >>>>Items. >>>>The resulting .html code looks correct. Why doesn't the color display? >>>>> >>>>Code >>>>DropDownListWorkLocation.BackColor = System.Drawing.Color.PowderBlue; >>>>DropDownListWorkLocation.ControlStyle.Back Color = System.Drawing.Color.PowderBlue; >>>>DropDownListWorkLocation.Attributes.CssSty le.Add("background-repeat", "repeat-y"); >>>>DropDownListWorkLocation.Attributes.CssSty le.Add("background-color", "powderblue"); >>>>DropDownListWorkLocation.Items[0].Attributes.Add("style", "color:powderblue"); >>>>for (int i = 0; i < DropDownListWorkLocation.Items.Count; i++) >>>>{ >>>>DropDownListWorkLocation.Items[i].Attributes.Add("style", "background-color:powderblue; "); >>>>} >>>>> >>>>Resulting HTML >>>>> >>>><td style="height: 20px;" nowrap="noWrap" width="19%"> >>>><select name="DropDownListWorkLocation" id="DropDownListWorkLocation" tabindex="9" >>>>style="font-weight:bold;width:90%;background-repeat:repeat-y;background-color:powderblue;"> >>>><option selected="selected" value="" style="background-color:powderblue; "></option> >>>><option value="123 Main Street" style="background-color:powderblue; ">123 Main Street</option> >>>><option value="456 Boulevard" style="background-color:powderblue; ">456 Boulevard</option> >>>><option value="789 Avenue" style="background-color:powderblue; ">789 Avenue</option> >>>></select> >>>></td> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Philip |
last post by:
Hey,
Is it possible to get the default value of an element's
style.backgroundColor property that's set in a css class?
Example, since I'm very tired and can't word that any better ;)
...
|
by: Stanley J Mroczek |
last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ?
<Columns>
<asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True"
HeaderText="Option...
|
by: RobG |
last post by:
When I set the background colour of an element using
tdRef.style.backgroundColor and then read it back, Firefox always
gives rgb(r, g, b) regardless of whether I've used rgb(...) or #rrggbb
to set...
|
by: cosmic foo |
last post by:
if i change the backgroundColor of a tag to 'red',
it works in both ie and mozilla.
if i change the backgroundColor of a tag to 'redd',
i get 'invalid property value' in ie, and no error in...
|
by: Gandalf |
last post by:
I wish to apply different styles to items in a DropDownList. However, any
styles applied in the codebehind (using the ListItem.Addtributes property)
do not get rendered. This is an old question but...
| |
by: jason |
last post by:
Pardon my ignorance on this. The below code works, except, when I edit
a record and update the two drop downs take the first entry in the
dropdownlist if not selected. I'd also like the dropdown to...
|
by: fallen angel |
last post by:
halu there!! i'm a 1month experienced java scripter but got a good hang of it already. hehehe.. i developed a "color selection" tool, similar to the one in flash when you choose a color for a...
|
by: André |
last post by:
Hi,
i created a table with cells. One cell has background-color (LightSlateGray)
and contains a label without text but also with a backgroundcolor (red). The
width of the label is set by a value...
|
by: asmx126453 |
last post by:
Hey mensen
I am having some big troubles here i tryd solving it myself with internet for 2 days but i kind fix it.
Its about this i have a DotNet project that alrydi is online and working for...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |